home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 13 / CU Amiga Magazine's Super CD-ROM 13 (1997)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1997-08].iso / CUCD / Graphics / Ghostscript / data / gs_dps1.ps < prev    next >
Text File  |  1997-04-12  |  9KB  |  303 lines

  1. %    Copyright (C) 1990, 1996 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for analogs of Display PostScript functions
  16. % that are also included in Level 2.
  17. % When this is run, systemdict is still writable,
  18. % but (almost) everything defined here goes into level2dict.
  19.  
  20. level2dict begin
  21.  
  22. % ------ Virtual memory ------ %
  23.  
  24. /currentshared /.currentglobal load def
  25. /scheck /.gcheck load def
  26. %****** FOLLOWING IS WRONG ******
  27. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  28.  
  29. % Global and LocalFontDirectory must remain in systemdict
  30. % even if we temporarily exit Level 2 mode.
  31.  
  32. end                % level2dict
  33. systemdict begin
  34.  
  35. /SharedFontDirectory FontDirectory .gcheck
  36.  { .currentglobal false .setglobal
  37.    /LocalFontDirectory FontDirectory dup maxlength dict copy def
  38.    .setglobal FontDirectory
  39.  }
  40.  { /LocalFontDirectory FontDirectory def
  41.    50 dict
  42.  }
  43. ifelse def
  44.  
  45. end                % systemdict
  46. level2dict begin
  47.  
  48. % setshared must rebind FontDirectory to the appropriate one of
  49. % Local or SharedFontDirectory.
  50.  
  51. /.setglobal
  52.  { .setglobal
  53.    //systemdict /FontDirectory .currentglobal
  54.     { //SharedFontDirectory }
  55.     { //systemdict /LocalFontDirectory get }    % can't embed ref to local VM
  56.    ifelse .forceput
  57.  } .bind odef        % must bind .forceput and .setglobal
  58.             % even if NOBIND in effect
  59. /setshared /.setglobal load def
  60. .currentglobal setshared
  61.  
  62. % ------ Fonts ------ %
  63.  
  64. /selectfont
  65.  { exch findfont exch
  66.    dup type /arraytype eq { makefont } { scalefont } ifelse
  67.    setfont
  68.  } odef
  69. % Undefinefont has to take local/global VM into account.
  70. /undefinefont
  71.  { FontDirectory 1 index .undef
  72.    .currentglobal
  73.     {        % Current mode is global; delete from local directory too.
  74.       //systemdict /LocalFontDirectory .knownget
  75.        { exch .undef }
  76.        { pop }
  77.       ifelse
  78.     }
  79.     {        % Current mode is local; if there was a shadowed global
  80.         % definition, copy it into the local directory.
  81.       //systemdict /SharedFontDirectory .knownget
  82.        { 1 index .knownget
  83.       { FontDirectory 3 1 roll put }
  84.       { pop }
  85.      ifelse
  86.        }
  87.       if
  88.     }
  89.    ifelse
  90.  } odef
  91.  
  92. % If we load a font into global VM within an inner save, the restore
  93. % will delete it from FontDirectory but not from SharedFontDirectory.
  94. % We have to handle this by making restore copy missing entries from
  95. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  96. % considerably, we define a new operator .dictcopynew for this purpose.
  97. % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
  98. % override fake local ones.  We handle this by brute force.
  99. /restore
  100.  { //restore
  101.    //systemdict /LocalFontDirectory get
  102.    FAKEFONTS
  103.     { mark
  104.         % We want to delete a fake font from the local directory
  105.         % iff the global directory now has no definition for it,
  106.         % or a non-fake definition.
  107.       1 index dup
  108.        {        % Stack: lfd mark lfd key ... lfd key value
  109.      length 1 gt
  110.       {        % This is a real local definition; don't do anything.
  111.         pop
  112.       }
  113.       {        % This is a fake local definition, check for global.
  114.         //SharedFontDirectory 1 index .knownget
  115.          {        % A global definition exists, check for fake.
  116.            length 1 eq { pop } { 1 index } ifelse
  117.          }
  118.          {        % No global definition, delete the local one.
  119.            1 index
  120.          }
  121.         ifelse
  122.       }
  123.      ifelse
  124.        } forall
  125.       pop counttomark 2 idiv { .undef } repeat pop
  126.     }
  127.    if
  128.    //SharedFontDirectory exch .dictcopynew pop
  129.  } bind odef
  130.  
  131. % ------ Halftones ------ %
  132.  
  133. /.makestackdict
  134.     { { counttomark -1 roll } forall .dicttomark
  135.     } bind def
  136. /currenthalftone
  137.     { mark .currenthalftone
  138.        { { exch pop }        % halftone
  139.          { /HalftoneType 1        % screen
  140.         { /Frequency /Angle /SpotFunction }
  141.            .makestackdict
  142.          }
  143.          { /HalftoneType 2        % colorscreen
  144.         { /RedFrequency /RedAngle /RedSpotFunction
  145.           /GreenFrequency /GreenAngle /GreenSpotFunction
  146.           /BlueFrequency /BlueAngle /BlueSpotFunction
  147.           /GrayFrequency /GrayAngle /GraySpotFunction
  148.         }
  149.            .makestackdict
  150.          }
  151.        }
  152.       exch get exec
  153.     } odef
  154. % Define sethalftone so it converts all other types to type 5.
  155. /.sethalftoneRGBV    % <dict> <type> <keys> <keysRGBV>
  156.     { 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll
  157.       14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red }
  158.        {        % stack: v0 v1 v2 type keys comp
  159.          mark
  160.          2 index 0 get 8 -1 roll
  161.          4 index 1 get 9 -1 roll
  162.          6 index 2 get 10 -1 roll
  163.             % stack: type keys comp mark k0 v0 k1 v1 k2 v2
  164.          /HalftoneType 10 index .dicttomark
  165.          counttomark 2 roll
  166.        }
  167.       forall pop pop
  168.       /Default 1 index .dicttomark .sethalftone5
  169.     } bind def
  170. /sethalftone
  171.     { dup /HalftoneType get 1 sub
  172.        {  { mark /Default 2 index .dicttomark .sethalftone5 }
  173.           { 1 { /Frequency /Angle /SpotFunction }
  174.         { /RedFrequency /RedAngle /RedSpotFunction
  175.           /GreenFrequency /GreenAngle /GreenSpotFunction
  176.           /BlueFrequency /BlueAngle /BlueSpotFunction
  177.           /GrayFrequency /GrayAngle /GraySpotFunction
  178.         } .sethalftoneRGBV
  179.           }
  180.           { mark /Default 2 index .dicttomark .sethalftone5 }
  181.           { 3 { /Width /Height /Thresholds }
  182.         { /RedWidth /RedHeight /RedThresholds
  183.           /GreenWidth /GreenHeight /GreenThresholds
  184.           /BlueWidth /BlueHeight /BlueThresholds
  185.           /GrayWidth /GrayHeight /GrayThresholds
  186.         } .sethalftoneRGBV
  187.           }
  188.           { dup .sethalftone5 }
  189.        } exch get exec
  190.     } odef
  191. % Redefine setscreen and setcolorscreen to recognize halftone dictionaries,
  192. % and to insert the Frequency and Angle into Type 1 halftones, per
  193. % Adobe TN 5085.
  194. /.fixsethalftonescreen
  195.  { dup /HalftoneType get 1 eq
  196.     { dup wcheck not { dup length .copydict } if
  197.       dup /Frequency 4 index put
  198.       dup /Angle 3 index put
  199.     }
  200.    if
  201.  } bind def
  202. /setscreen
  203.     { dup type /dicttype eq
  204.        { .fixsethalftonescreen sethalftone pop pop }
  205.        { //setscreen }
  206.       ifelse
  207.     } odef
  208. /setcolorscreen
  209.     { dup type /dicttype eq
  210.        { .fixsethalftonescreen sethalftone 11 { pop } repeat }
  211.        { //setcolorscreen }
  212.       ifelse
  213.     } odef
  214. % Redefine currentscreen and currentcolorscreen to extract the Frequency
  215. % and Angle from Type 1 halftones, per Adobe TN 5085.
  216. /.fixcurrenthalftonescreen    % <dict> .fix... <freq> <angle> <proc>
  217.  { dup /HalftoneType get 1 eq
  218.     { dup /Frequency get 1 index /Angle get }
  219.     { 60 0 }
  220.    ifelse 3 2 roll
  221.  } bind def
  222. /currentscreen
  223.     { .currenthalftone
  224.        { { .fixcurrenthalftonescreen }    % halftone
  225.          { }                % screen
  226.          { 12 3 roll 9 { pop } repeat    % colorscreen
  227.            dup type /dicttype eq { .fixcurrenthalftonescreen } if
  228.          }
  229.        }
  230.       exch get exec
  231.     } odef
  232. /currentcolorscreen
  233.     { .currenthalftone
  234.        { { .fixcurrenthalftonescreen 3 copy 6 copy }    % halftone
  235.          { 3 copy 6 copy }            % screen
  236.          { }                % colorscreen
  237.        }
  238.       exch get exec
  239.     } odef
  240.  
  241. % ------ User objects ------ %
  242.  
  243. /.localarray where
  244.  { pop }
  245.  { /.localarray
  246.     { currentglobal false setglobal
  247.       exch array exch setglobal
  248.     } bind def
  249.  }
  250. ifelse
  251. /defineuserobject
  252.     { userdict /.UserObjects known
  253.        { 1 index userdict /.UserObjects get length ge
  254.           { 1 index 1 add .localarray userdict /.UserObjects get
  255.         1 index copy pop
  256.         userdict /.UserObjects 3 -1 roll put
  257.           }
  258.          if
  259.        }
  260.        { userdict /.UserObjects 3 index 1 add .localarray put
  261.        }
  262.       ifelse
  263.       userdict /.UserObjects get 3 1 roll put
  264.     } odef
  265. /execuserobject
  266.     { userdict /.UserObjects get exch get exec
  267.     } odef
  268. /undefineuserobject
  269.     { userdict /.UserObjects get exch null put
  270.     } odef
  271.  
  272. % ------ User paths ------ %
  273.  
  274. % We define upath carefully so it won't leave garbage on the stack
  275. % if an error occurs.
  276. /upath
  277.     { [
  278.        { 1 index {/ucache cvx} if true .pathbbox /setbbox cvx
  279.          {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
  280.          pathforall ]
  281.        }
  282.       .internalstopped
  283.        { cleartomark /upath load $error /errorname get signalerror
  284.        }
  285.       if cvx exch pop
  286.     } odef
  287.  
  288. % Dummy definitions for cache control operators
  289.  
  290. /ucachestatus
  291.     { mark 0 0 0 0 0 } odef
  292. /setucacheparams
  293.     { cleartomark } odef
  294.  
  295. % ------ Miscellaneous ------ %
  296.  
  297. /undef /.undef load def
  298.  
  299. end                % level2dict
  300.